//
// Created by klen on 23-11-25.
//

#include <memory>  // for allocator, __shared_ptr_access, shared_ptr
#include <string>  // for string, basic_string
#include <vector>  // for vector

#include "ftxui/component/captured_mouse.hpp"  // for ftxui
#include "ftxui/component/component.hpp"  // for Radiobox, Horizontal, Menu, Renderer, Tab
#include "ftxui/component/component_base.hpp"      // for ComponentBase
#include "ftxui/component/screen_interactive.hpp"  // for ScreenInteractive
#include "ftxui/dom/elements.hpp"  // for Element, separator, hbox, operator|, border



int main() {
    using namespace ftxui;

    // 创建一个窗口, 标题居中,加粗 , 内容居中变暗, 窗口大小为 宽度:dimx, 高度:dimy
    auto make_box = [](int dimx, int dimy) {
        std::string title = std::to_string(dimx) + "x" + std::to_string(dimy);
        return window(text(title) | hcenter | bold,
                      text("content") | hcenter | dim) |
               size(WIDTH, EQUAL, dimx) | size(HEIGHT, EQUAL, dimy);
    };

    auto style = size(WIDTH, GREATER_THAN, 20) | border |
                 size(HEIGHT, GREATER_THAN, 30) | size(WIDTH, LESS_THAN, 50);

    auto elm = hflow({
                                  make_box(7, 7),
                                  make_box(7, 5),
                                  make_box(5, 7),
                                  make_box(10, 4),
                                  make_box(10, 4),
                                  make_box(10, 4),
                                  make_box(10, 4),
                                  make_box(11, 4),
                                  make_box(11, 4),
                                  make_box(11, 4),
                                  make_box(11, 4),
                                  make_box(12, 4),
                                  make_box(12, 5),
                                  make_box(12, 4),
                                  make_box(13, 4),
                                  make_box(13, 3),
                                  make_box(13, 3),
                                  make_box(10, 3),
                          }) |
                    style;
    // 创建一个屏幕, 宽度为全屏, 高度根据元素大小伸展
    auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(elm));

    // 将元素设置在屏幕对象中展现
    Render(screen, elm);

    // 打印屏幕
    screen.Print();

}